package com.qf.personal.controller;

import com.qf.common.base.result.RespResult;
import com.qf.personal.entiy.Type;
import com.qf.personal.service.TypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "事项类型")
@RestController
@RequestMapping("/type")
public class TypeController {
    @Resource
    private TypeService typeService;

    @GetMapping("/select")
    @ApiOperation("查询所有类型")
    @ApiResponses({@ApiResponse(code = 200, message = "成功")})
    public RespResult<List<Type>> selectAll() {
        return typeService.selectAll();
    }

    @PutMapping("/select/one")
    @ApiOperation("查询具体类型")
    @ApiResponses({@ApiResponse(code = 200, message = "成功")})
    public RespResult<List<Type>> selectById(Type type) {
        return typeService.selectById(type);
    }

    @PutMapping("/search")
    @ApiOperation("搜索类型")
    @ApiResponses({@ApiResponse(code = 200, message = "成功")})
    public RespResult<List<Type>> search(Type type) {
        return typeService.searchType(type);
    }
}
